from django.shortcuts import render

# Create your views here.
from rest_framework import mixins, viewsets
from rest_framework.viewsets import ModelViewSet

from activity.models import Activity
from activity.serializers import ActivitySerializer
from news.utils import StandardResultsSetPagination


class ActivityView(mixins.RetrieveModelMixin,
                   mixins.ListModelMixin,
                   viewsets.GenericViewSet):
    """
        list:
            活动列表
        retrieve:
            活动详情
    """
    permission_classes = ()
    authentication_classes = ()
    queryset = Activity.objects.all()
    serializer_class = ActivitySerializer
    pagination_class = StandardResultsSetPagination

    def get_queryset(self):
        return Activity.objects.all().order_by('add_time')